/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Created by IntelliJ IDEA.
 * User: pharacyde
 * Date: 02/01/13
 * Time: 19:24
 */
package be.free.ts.infrastructure.web;

import be.free.ts.activity.web.*;
import be.free.ts.contact.web.*;
import be.free.ts.customer.web.*;
import be.free.ts.employee.web.*;
import be.free.ts.project.web.*;
import be.free.ts.timesheet.web.*;
import be.free.ts.web.MainPresenter;
import be.free.ts.web.MainView;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import net.customware.gwt.dispatch.client.DefaultExceptionHandler;
import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.dispatch.client.ExceptionHandler;
import net.customware.gwt.dispatch.client.standard.StandardDispatchAsync;
import net.customware.gwt.presenter.client.DefaultEventBus;
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.gin.AbstractPresenterModule;

public class PresenterGinModule extends AbstractPresenterModule {
	@Override
	protected void configure() {

		bind(EventBus.class).to(DefaultEventBus.class).asEagerSingleton();
		bind(ExceptionHandler.class).to(DefaultExceptionHandler.class);

		//web
		bindPresenter(MainPresenter.class, MainPresenter.Display.class, MainView.class);

		//activity
		bindPresenter(ActivityPresenter.class, ActivityPresenter.Display.class, ActivityView.class);
		bindPresenter(CreateActivityPresenter.class, CreateActivityPresenter.Display.class, CreateActivityView.class);
		bindPresenter(EditActivityPresenter.class, EditActivityPresenter.Display.class, EditActivityView.class);
		bindPresenter(ListActivitiesPresenter.class, ListActivitiesPresenter.Display.class, ListActivitiesView.class);

		// contact binding
		bindPresenter(ContactPresenter.class, ContactPresenter.Display.class, ContactView.class);
		bindPresenter(CreateContactPresenter.class, CreateContactPresenter.Display.class, CreateContactView.class);
		bindPresenter(EditContactPresenter.class, EditContactPresenter.Display.class, EditContactView.class);
		bindPresenter(ListContactsPresenter.class, ListContactsPresenter.Display.class, ListContactsView.class);

		//customer
		bindPresenter(CustomerPresenter.class, CustomerPresenter.Display.class, CustomerView.class);
		bindPresenter(CreateCustomerPresenter.class, CreateCustomerPresenter.Display.class, CreateCustomerView.class);
		bindPresenter(EditCustomerPresenter.class, EditCustomerPresenter.Display.class, EditCustomerView.class);
		bindPresenter(ListCustomersPresenter.class, ListCustomersPresenter.Display.class, ListCustomersView.class);

		//employee
		bindPresenter(EmployeePresenter.class, EmployeePresenter.Display.class, EmployeeView.class);
		bindPresenter(CreateEmployeePresenter.class, CreateEmployeePresenter.Display.class, CreateEmployeeView.class);
		bindPresenter(EditEmployeePresenter.class, EditEmployeePresenter.Display.class, EditEmployeeView.class);
		bindPresenter(ListEmployeesPresenter.class, ListEmployeesPresenter.Display.class, ListEmployeesView.class);

		//project
		bindPresenter(ProjectPresenter.class, ProjectPresenter.Display.class, ProjectView.class);
		bindPresenter(CreateProjectPresenter.class, CreateProjectPresenter.Display.class, CreateProjectView.class);
		bindPresenter(EditProjectPresenter.class, EditProjectPresenter.Display.class, EditProjectView.class);
		bindPresenter(ListProjectsPresenter.class, ListProjectsPresenter.Display.class, ListProjectsView.class);

		//timesheet
		bindPresenter(TimesheetPresenter.class, TimesheetPresenter.Display.class, TimesheetView.class);
		bindPresenter(CreateTimesheetPresenter.class, CreateTimesheetPresenter.Display.class, CreateTimesheetView.class);
		bindPresenter(EditTimesheetPresenter.class, EditTimesheetPresenter.Display.class, EditTimesheetView.class);
		bindPresenter(ListTimesheetsPresenter.class, ListTimesheetsPresenter.Display.class, ListTimesheetsView.class);

	}

	@Provides
	@Singleton
	public DispatchAsync standardDispatchAsync(ExceptionHandler exceptionHandler) {
		return new StandardDispatchAsync(exceptionHandler);
	}
}